<template>
	<view class="">
		<view class="top">
		</view>
		<view class="container">
			<view>
				<view class="user-info">
					<view class="user-details">
						<view class="flex">
							<image class="user-avatar" :src="rq.imgUrl(userInfo.avatar)" />
							<view class="user-nickname">{{userInfo.nickname}}</view>
						</view>
						<view class="user-stats">
							<view>
								<view class="text-r">注册时间: {{model.Register?model.Register:0}}天</view>
								<text class="text-top">消费金额: {{model.Money?model.Money:0}}元</text>
							</view>
							<view>
								<view class="text-r">邀请下单: {{model.PlaceOrder?model.PlaceOrder:0}}单</view>
								<text class="text-top">邀请接单: {{model.Receive?model.Receive:0}}人</text>
							</view>
							<view>
								<view class="text-r">发布活动: {{model.Activity?model.Activity:0}}</view>
								<text class="text-top">发布帖子: {{model.Dynamic?model.Dynamic:0}}单</text>
							</view>
							<view class="text-b">
							</view>
							<view>
								<view class="text-r">成为达人: {{model.Expert?model.Expert:0}}天</view>
								<text class="text-top">达人评分: {{model.Grade?model.Grade:0}}分</text>
							</view>
							<view>
								<view class="text-r">获赞数量: {{model.Upvote?model.Upvote:0}}</view>
								<text class="text-top">完结订单: {{model.Over?model.Over:0}}单</text>
							</view>							
						</view>
					</view>
				</view>
			</view>

			<view class="task-list">
				<view class="task-item" v-for="item,index in list" :key="index">
					<view class="task_left">
						<view class="task-title">{{item.name}} <text class="title-f">({{item.type_text}})</text></view>
						<view class="task-requirements">{{item.condition}}</view>
					</view>
					<view class="task-button" @click="ling(item)" v-if="item.draw==2">领取</view>
					<view class="task-button green"  v-else-if="item.draw==1">√</view>
					<view class="task-button hui" v-else>未达到</view>
					
				</view>
			
			</view>
		</view>
	</view>

</template>

<script>
	export default {
		data(){
			return{
				model:{},
				list:[],
				userInfo:{}
			}
		},
		onLoad() {
			this.userInfo=JSON.parse(uni.getStorageSync('userInfo'))
			this.getData()
		},
		methods:{
			getData(){
				this.rq.getData('task/user').then(res=>{
					this.model = res.data
				})
				this.getList()
			},
			getList(){
				this.rq.getData('task/index').then(res=>{
					this.list = res.data.list.data

				})
			},
			ling(item){
				this.rq.getData('task/draw',{id:item.id}).then(res=>{
					this.getData()
				})
				
			}
		}
	}
</script>

<style scoped>
	.title-f {
		color: #FF7681;
	}

	.text-top {
		margin-bottom: 10rpx;
		/* margin-top: 10rpx; */
	}

	.text-b {
		width: 100%;
		border-bottom: 1px solid #fff;
		margin: 20rpx 0;
	}

	.text-r {
		margin-bottom: 10rpx;
		/* margin-top: 10rpx; */
		border-right: 1px solid #e0e0e0;
		margin-right: 40rpx;
		font-size: 28rpx;
		width: 280rpx;
	}

	.flex {
		display: flex;
	}

	.top {
		height: 300rpx;
		width: 100%;
		background: linear-gradient(180deg, #FFD3D7 -2%, rgba(255, 206, 191, 0) 100%);
	}

	.container {
		position: absolute;
		top: 0;
		margin: 20px;
		background-color: linear-gradient(180deg, #FFD3D7 -2%, rgba(255, 206, 191, 0) 100%);

	}

	.user-info {
		background-image: url(https://pw.qyang.cc/static/my-icon-bg1.png);
		background-size: 100% 100%;
		background-repeat: no-repeat;
		background-position: center;
		display: flex;
		/* align-items: center; */
		/* background-color: #ff5e7e; */
		padding: 42rpx 0 30rpx 50rpx;
		border-radius: 10px;
		margin-bottom: 20px;
		/* height: 464rpx; */
	}

	.user-avatar {
		width: 100rpx;
		height: 100rpx;
		border-radius: 50%;
		margin-right: 20px;
		margin-bottom: 20rpx;
	}

	.user-details {
		color: white;
	}

	.user-nickname {
		line-height: 100rpx;
		font-size: 28rpx;
		/* font-weight: bold; */
	}

	.user-stats {
		display: flex;
		flex-wrap: wrap;
	}
	.user-stats view{
		display: flex;
	}
	.user-stats text {
		margin-right: 20rpx;
		/* margin-bottom: 10rpx; */
		font-size: 28rpx;
	}

	.task-list {
		/* background-color: white; */
		border-radius: 10px;
		/* padding: 20px; */
	}

	.task-item {
		background-color: white;
		padding: 40rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		/* padding: 10px 0; */
		margin-bottom: 28rpx;
		/* border-bottom: 1px solid #e0e0e0; */
	}

	.task-item:last-child {
		border-bottom: none;
		border-radius: 16rpx;
	}

	.task-title {
		font-size: 30rpx;
		line-height: 36rpx;
		font-weight: bold;
	}

	.task-requirements {
		color: #888;
		margin-top: 4rpx;
		line-height: 36rpx;
		font-size: 24rpx;
		/* margin-left: 10px; */
	}

	.task-button {
		background-color: #ff5e7e;
		padding: 0;
		border:0;
		width: 110rpx;
		height: 44rpx;
		line-height: 44rpx;
		font-size: 26rpx;
		color: white;
		text-align: center;
		/* float: right; */
		bottom: 72rpx;
		border-radius: 40rpx;
		
	}
	.task-button.hui{
		background-color: #E3E3E3;
		font-size: 24rpx
	}
	.task-button.green{
		background-color: #84E28C;
	}
	
</style>